﻿<MudDataGrid Items="@_items" Sortable="true">
    <Columns>
        <PropertyColumn Property="x => x.Name" />
        <PropertyColumn Property="x => x.Value" />
        <PropertyColumn Property="x => x.Misc" SortBy="@(item => item.Misc.Length)" />
    </Columns>
</MudDataGrid>

@code {
    public static string __description__ = @"Test in-browser-sorting of DataGrid. Hold <Ctrl> key when clicking header to extend to multi sort. Hold <Alt> key to unsort a sorted column.
Note that the 'Misc' column is being sorted by length and not by the content itself.";


    private readonly IEnumerable<Item> _items = new List<Item>
    {
        new("B", 42, "555"), 
        new("A", 73, "7"), 
        new("A", 11, "4444"), 
        new("C", 33, "33333"),
        new("A", 99, "66"), 
        new("C", 44, "1111111"),
        new("C", 55, "222222")
    };

    public class Item(string name, int value, string misc)
    {
        public string Name { get; set; } = name;

        public int Value { get; set; } = value;

        public string Misc { get; set; } = misc;
    }
}
